package action

import (
	"context"
	"trusteva/app/rbac/model"

	"trusteva/app/rbac/internal/svc"
	"trusteva/app/rbac/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ActionCreateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewActionCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ActionCreateLogic {
	return &ActionCreateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ActionCreateLogic) ActionCreate(req *types.ActionCreateRo) (resp *types.BaseRsp, err error) {
	err = l.svcCtx.DB.Create(&model.ActionConfig{
		Name:   req.Name,
		Path:   req.Path,
		Method: req.Method,
		Status: 0,
	}).Error

	return
}
